import { useState, useEffect, useContext } from 'react';
import { Modal, Tree, Input, Checkbox, message, Button } from 'antd';
import { ApartmentOutlined } from '@ant-design/icons';

import styles from './style.less';

const Child1 = ({ fatherContext }) => {
  const [checkedKeys, setCheckedKeys] = useState([]);
  // 3. 子组件中---使用 useContext
  const { preferences, setPreferences } = useContext(fatherContext);
  console.log('preferences', preferences);
  return (
    <>
      <div>Child1</div>
      <Button
        // onClick={setPreferences((prev) => ({
        //   ...prev,
        //   theme: 'theme--Child1',
        // }))}
        onClick={() => {
          setPreferences({
            ...preferences,
            theme: 'theme--Child1',
          });
        }}
      >
        Child1=={preferences.theme}
      </Button>
      {/* <div>: {preferences}</div> */}
    </>
  );
};

export default Child1;
